package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.object.pojo.GeoRegionBound;
import com.tbit.uqbike.object.view.JsonResult;
import com.tbit.uqbike.service.business.GeoRegionBoundService;
import com.tbit.uqbike.webmanager.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 运维分区绑定(GeoRegionBound)表控制层
 *
 * @author jing
 * @since 2020-11-24 09:43:40
 */
@RestController
@RequestMapping("/georegionbound")
public class GeoRegionBoundController {
    /**
     * 服务对象
     */
    @Resource
    private GeoRegionBoundService geoRegionBoundService;

    /**
     * 根据分区id查询绑定的分区人员
     *
     * @param regionId 主键
     * @return 单条数据
     */
    @PostMapping("/selectList")
    public JsonResult selectList(Integer regionId) {
        Assert.notNull(regionId, "ver.regionId.notNull");
        return JsonResult.ok(this.geoRegionBoundService.queryById(regionId));
    }

    /**
     * 新增
     */
    @PostMapping("/add")
    public JsonResult add(GeoRegionBound geoRegionBound) {
        geoRegionBoundService.insert(geoRegionBound);
        return JsonResult.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public JsonResult delete(GeoRegionBound geoRegionBound) {
        Assert.notNull(geoRegionBound.getRegionId(), "ver.regionId.notNull");
        Assert.notNull(geoRegionBound.getAccountUserId(), "ver.accountUserId.notNull");
        geoRegionBoundService.deleteById(geoRegionBound.getRegionId(), geoRegionBound.getAccountUserId());
        return JsonResult.ok();
    }
}